//
//  YDInquiryResultCell.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/3/2.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDInquiryResultCell.h"

@interface YDInquiryResultCell()


@property (nonatomic , weak) UIView *lineView;



@end

@implementation YDInquiryResultCell


+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *inquiryResultCell = @"YDInquiryResultCell";
    YDInquiryResultCell *cell = [tableView dequeueReusableCellWithIdentifier:inquiryResultCell];
    if (cell == nil) {
        cell = [[YDInquiryResultCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:inquiryResultCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor whiteColor];
        
        [self lineView];
        
        [self cateLabel];
        
        [self contentLabel];
        
        [self questionImage];

    }
    return self;
}

/****cateLabel*****/
-(UILabel *)cateLabel
{
    if (_cateLabel == nil) {
        UILabel *cateLabel = [[UILabel alloc] init];
        [self.contentView addSubview:cateLabel];
        cateLabel.textColor = [UIColor colorWithHexString:dark];
        cateLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        cateLabel.textAlignment = NSTextAlignmentLeft;
        cateLabel.text = @"类别：";
        [cateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.equalTo(self).offset(rate375(20));
        }];
        _cateLabel = cateLabel;
    }
    return _cateLabel;
}
-(UILabel *)contentLabel
{
    if (_contentLabel == nil) {
        UILabel *contentLabel = [[UILabel alloc] init];
        [self.contentView addSubview:contentLabel];
        contentLabel.textColor = [UIColor colorWithHexString:dark];
        contentLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        contentLabel.textAlignment = NSTextAlignmentRight;
        contentLabel.text = @"期权内容";
        [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.right.equalTo(self).offset(-rate375(20));
        }];
        _contentLabel = contentLabel;
    }
    return _contentLabel;
}
-(UIView *)lineView
{
    if (_lineView == nil) {
        UIView *lineView = [[UIView alloc] init];
        [self.contentView addSubview:lineView];
        lineView.backgroundColor = NumberColor(247, 247, 247);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self);
            make.height.equalTo(@1);
        }];
        _lineView = lineView;
    }
    return _lineView;
}
-(UIImageView *)questionImage
{
    if (_questionImage == nil) {
        UIImageView *questtionImage = [[UIImageView alloc] init];
        [self.contentView addSubview:questtionImage];
        questtionImage.userInteractionEnabled = YES;
        [questtionImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-rate375(20));
            make.centerY.equalTo(self);
        }];
        questtionImage.image = [UIImage imageNamed:@"zdqq-zhujie"];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
        [questtionImage addGestureRecognizer:tap];
        
        _questionImage = questtionImage;
    }
    return _questionImage;
}

-(void)tapClick
{
    if (self.questionClick) {
        self.questionClick();
    }
}
-(void)updateCellConstraints
{
    
    [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.questionImage.mas_left).offset(-rate375(10));
        make.centerY.equalTo(self);
    }];
}
@end
